// src/utils/auth.ts

const TOKEN_KEY = "app-token";

export function getToken(): string | null {
  return localStorage.getItem(TOKEN_KEY);
}

export function setToken(token: string): void {
  localStorage.setItem(TOKEN_KEY, token);
}

export function removeToken(): void {
  localStorage.removeItem(TOKEN_KEY);
}

const LOGIN_HANDLE_KEY = "app-login-handle";

export function getLoginHandle(): number | null {
  const handle = localStorage.getItem(LOGIN_HANDLE_KEY);
  return handle ? Number(handle) : null;
}

export function setLoginHandle(handle: number): void {
  localStorage.setItem(LOGIN_HANDLE_KEY, handle.toString());
}

export function removeLoginHandle(): void {
  localStorage.removeItem(LOGIN_HANDLE_KEY);
}
